#pragma once
#include "structures.h"

std::string banner() {
	printf(
		"+----------------------------------------+\n"
		"|     LZ Encode And Decode Procedure     |\n"
		"+----------------------------------------+\n"
	);
	std::string fname;
	std::cout << "Please enter the filename to encode and decode: \n";
	std::getline(std::cin, fname);
	return fname;
}


/* print the progress bar |=======>| */
void progress_bar(double progress, const char* phase)
{
	const size_t barlength = 50;
	size_t pg = (size_t)(progress * barlength), j = 0;
	printf("%s Progress |", phase);
	for (; j < pg; j++) putchar('=');
	putchar('>');
	for (; j < barlength; j++) putchar(' ');
	printf("| %.2lf%%\r", progress * 100);
	fflush(stdout);
}

void printsymtab(Entry* dict, size_t dictlen)
{
	const size_t symcnt = 100;
	printf("===First %d Dictionary Entry===\n", symcnt);
	printf("index\tlength\tword\tj\tc\n");
	dictlen = dictlen < symcnt ? dictlen : symcnt;
	for (size_t i = 1; i < dictlen; i++)
	{
		Entry* e = &dict[i];
		printf("%d\t%d\t", e->idx,
			e->len);
		for (size_t j = 0; j < e->len; j++)
		{
			printf("%02x", e->word[j]);
		}
		printf("\t%d\t0x%02x\n", e->prev_idx, e->append);
	}
}